package com.yihaodian.search.core;

import java.io.IOException;

import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.store.Directory;

import com.yihaodian.api.search.SearchException;

public class SimpleSearcher implements Searcher {
	IndexReader reader;

	public SimpleSearcher(Directory directory) throws IOException {
		reader = DirectoryReader.open(directory);
	}

	@Override
	public boolean release() throws SearchException {
		return false;
	}

	@Override
	public IndexReader reader() {
		return reader;
	}

	@Override
	public IndexSearcher searcher() {
		return new IndexSearcher(reader);
	}

}
